﻿
using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Utility;
using YouHP.BLL;
using YouHP.Model;
using YouHP.Model.Group;

namespace YouHP.Pages.User
{
    public class LogDel : YouHP.Pages.User.UserBasePage
    {
        protected override void ShowPage()
        {
            base.ShowPage();
            if (ErrorCount > 0) return;
            
            HandleGet();
        }

     

        protected void HandleGet()
        {
            int lid = RequestTools.GetInt("lid", 0);
            if (lid <= 0)
            {
                this.AddErrLine("无效的参数 lid");
                return;
            }
            LogTopicInfo tdata = LogTopicBLL.Instance.GetLogTopicInfo(lid);
            if (tdata.Id <= 0)
            {
                this.AddErrLine("日志不存在或已被删除");
                return;
            }
            if (tdata.HostUserId != UserData.Id)
            {
                this.AddErrLine("您没有权限删除该日志");
                return;
            }
            bool succ = LogTopicBLL.Instance.DeleteLogTopic(tdata.Id);   
            if (succ == true)
            {
                this.Redirect("/User/LogList.aspx");
            }
            else
            {
                
                this.AddErrLine("删除失败");
                this.SetShowBackLink(true);
                return;
            }
        }
    }
}